package leetcode01_10;

import org.junit.Test;

/**
 * @author shhjiang_001
 * @create 2020-03-09 13:24
 */
public class Solution07 {
    public int reverse(int x) {
        int ans = 0;
        int neg= x>0? 1:-1;
        x*=neg;
        while (x>0){
            if (ans*10/10 != ans) return 0;
            ans = ans*10+x%10;
            x = x/10;
        }
        return ans*neg;

    }

    @Test
    public void test(){
        Solution07 solution07 = new Solution07();
        int i = solution07.reverse(2147483642);
        System.out.println(i);
    }
}
